package com.neca.auction.pages;

import org.apache.tapestry.annotations.ApplicationState;
import org.apache.tapestry.annotations.Persist;

import com.neca.auction.dbb.DBBroker;
import com.neca.auction.model.CurrentUser;
import com.neca.auction.model.User;


public class Account {
	@ApplicationState
	private CurrentUser currentUser;
	DBBroker dbbroker=DBBroker.getDbbroker();
	
	
	
	
	@Persist
	private User user;
	
	public User getUser() {
		
		System.out.println(currentUser.getUserName());
		return this.user;
		
	}

	public void setUser(User user) {
		System.out.println(user.getFirstName());
		this.user = user;
	}
	
	void onSubmitFromUserEditor(){
		System.out.println("The form was submitted!!!");
		
	}
	
	void onValidate(){
		
	}
	Object onSuccess(){
		DBBroker dbbroker=DBBroker.getDbbroker();
		dbbroker.addUser(user);
		return MainNavigation.class;
		
	}
	
	
	void onActivate(){
		
		user=dbbroker.getUserByUserName(new User("","",currentUser.getUserName(),"","","",0));
		
		
	}
	
	

}
